package com.fallsvc.re.javase.exception;

/**
 * @auther falls_vc
 * description:
 * @date 2025/10/13  10:37
 */
public class Demo1 {
    public static int getElement(int[] array, int index){
        if(null == array){
            throw new NullPointerException("传递的数组为null");
        }
        if(index < 0 || index >= array.length){
            throw new ArrayIndexOutOfBoundsException("传递的数组下标越界");
        }
        return array[index];
    }
    public static void main1(String[] args) {
        int[] array = {1,2,3};
        getElement(array, 3);
    }

    public static void main(String[] args) {
        System.out.println(func());
    }
    public static int func() {
        try {
            return 10;
        } finally {
            return 20;
        }

    }
}
